package com.huaao.micropolice.core.model.system;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;


/**
 * @author qiyang
 * 部门
 * @version 1.0
 */
public class Dept implements Serializable{
	public static final Integer LEAF_YES=1;
	public static final Integer LEAF_NO=0;
	private String id;
	private String name;
	private String code;
	private String address;
	private String phone;
	private String email;
	private Integer leve;
	private String mark;
	private Integer isLeaf;
	
	
	public Integer getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(Integer isLeaf) {
		this.isLeaf = isLeaf;
	}
	 
	private Dept parent;
	private Set<Dept> children = new LinkedHashSet<Dept>();
	
	private DeptType type = DeptType.gongsi;
	
	public static enum DeptType {
        gongsi("公司"), bumen("部门"),xiaozu("小组");

        private final String info;
        private DeptType(String info) {
            this.info = info;
        }

        public String getInfo() {
            return info;
        }
    } 
	
	private Area area;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Dept getParent() {
		return parent;
	}

	public void setParent(Dept parent) {
		this.parent = parent;
	}

	public Set<Dept> getChildren() {
		return children;
	}

	public void setChildren(Set<Dept> children) {
		this.children = children;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getLeve() {
		return leve;
	}

	public void setLeve(Integer leve) {
		this.leve = leve;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	public DeptType getType() {
		return type;
	}

	public void setType(DeptType type) {
		this.type = type;
	}
	
	public String getParentId() {
		if(this.parent != null){
			return this.parent.getId();
		}
		return null;
	}
	public String getParentCode() {
		if(this.parent != null){
			return this.parent.getCode();
		}
		return null;
	}
	
	public String getParentName() {
		if(this.parent != null){
			return this.parent.getName();
		}
		return null;
	}
	
	public String getAreaId(){
		if(this.area != null){
			return this.area.getId();
		}
		return null;
	}
	
	public void setParentId(String pid){
		Dept obj = new Dept();
		obj.setId(pid);
		this.setParent(obj);
	}
	
	public void setAreaId(String id){
		Area obj = new Area();
		obj.setId(id);
		this.setArea(obj);
	}
	
	public String getAreaName(){
		if(this.area != null){
			return this.area.getName();
		}
		return null;
	}
	
	public String getIsLeafName(){
		return this.isLeaf == 0? "false":"true";
	}
}
